{extend name="public:_base" /}

{block name="css"}
<style type="text/css">
    .bak-update {
        display: none;
    }
</style>
{/block}

{block name="main"}

<div class="page-container">

    <div class="Huialert Huialert-info">
        <i class="Hui-iconfont">&#xe6a6;</i>
        <h4 title="提示相关设置操作时应注意的要点">操作提示</h4>
        <ul>
            <li> 数据还原, 点击恢复选项进行数据库导入.</li>
        </ul>
    </div>

    {include file="bak/bar" /}

    <div class="mDiv">
        <div class="ftitle">
            <h3>sql文件列表</h3>
            <h5>(备份文件数量：{$filenum}，占空间大小：{$total|format_bytes})</h5>
        </div>
        <div title="刷新数据" class="pReload"><i class="fa fa-refresh"></i></div>
    </div>
    <div class="mt-10">
        <table id="tb_flexigrid" class="layui-table">
            <thead>
                <tr class="text-c">
                    <th width="20"><input name="" type="checkbox" value=""></th>
                    <th>文件名称</th>
                    <th width="80">系统版本</th>
                    <th width="40">卷号</th>
                    <th width="80">压缩</th>
                    <th width="100">数据大小</th>
                    <th width="120">备份时间</th>
                    <th width="180">操作</th>
                </tr>
            </thead>
            <tbody>
                {empty name="list"}
                <tr>
                    <td class="no-data" align="center" axis="col0" colspan="50">
                        <i class="fa fa-exclamation-circle"></i>没有符合条件的记录
                    </td>
                </tr>
                {else/}
                {volist name="list" id="vo" empty="$_html_empty"}
                <tr data-id="{$vo.basename}">
                    <td class="sign">
                        <div class="w40 tc"><input type="checkbox" name="ids[]" value="{$vo.time}"></div>
                    </td>
                    <td>
                        <div>{$vo.basename}</div>
                    </td>
                    <td>
                        <div class="w100 tc">{$vo.version}</div>
                    </td>
                    <td class="">
                        <div class="w40 tc">{$vo.part}</div>
                    </td>
                    <td>
                        <div class="w60 tc">{$vo.compress}</div>
                    </td>
                    <td>
                        <div class="w100 tc">{$vo.size|format_bytes}</div>
                    </td>
                    <td>
                        <div class="w160 tc">{$vo.time|date="Y-m-d H:i:s",###}</div>
                    </td>

                    <td>
                        <div class="w160 tc">
                            <a href="javascript:void(0);"
                                data-url="{:url('bak/new_import', array('time'=>$vo['time']))}"
                                class="btn radius btn-xs btn-success db-import"><i class="fa fa-repeat"></i>恢复</a>
                            <a href="{:url('bak/downFile',array('time'=>$vo['time']))}"
                                class="btn radius btn-xs  btn-primary"><i class="fa fa-download "></i>下载</a>
                            <a class="btn radius btn-xs  btn-danger" href="javascript:void(0);" data-id="{$vo.time}"
                                onClick="del('{:url('bak/bakdel')}',{$vo.time});"><i class="fa fa-trash-o"></i>删除</a>
                        </div>
                    </td>

                </tr>
                {/volist}

                {/empty}
            </tbody>
        </table>
        <form class="none" name="form_tmp" id="form_tmp" action="" method="POST">

        </form>
    </div>
</div>
{/block}
{block name="js"}
<script>
    $(document).ready(function () {
        // 表格行点击选中切换
        $('#flexigrid > table>tbody >tr').click(function () {
            $(this).toggleClass('trSelected');
        });

        // 点击刷新数据
        $('.fa-refresh').click(function () {
            location.href = location.href;
        });

        $('#sqlfile').change(function () {
            restoreUpload();
        });

        function restoreUpload() {
            var sqlfile = $('input[name=sqlfile]').val();
            var ext = sqlfile.substr(sqlfile.lastIndexOf('.')).toLowerCase();
            if ($.trim(sqlfile) == '' || ext != '.sql') {
                showErrorMsg('请上传sql文件！');
                return false;
            }

            layer.confirm('此操作不可逆，确认执行？', {
                title: '<font color="red">重要提示</font>',
                btn: ['确定', '取消'] //按钮
            }, function () {
                layer_loading('正在处理');
                $('#change_System').submit();
                return false;
            }, function (index) {
                $('#sqlfile').val('');
                layer.closeAll();
                return false;
            });
        }

    });


    function postbak(url, tablename) {
        $.post(url,function (data) {
            //没有权限返回信息
            if (data.status == '0') {
                layer.alert(data.msg);
            }
            if (data.status == "1") {
                layer.alert(data.msg);
                layer_close();
            }
        }, 'json')
    }


    $(".db-import").click(function () {
        var url = $(this).attr('data-url');
        $('#form_tmp').attr('action', url);
        layer.load();
        $.post(url, function (data) {
            //没有权限返回信息
            if (data.status == '0') {
                layer.alert(data.msg);
            }
            if (data.status == "1") {
                layer.alert(data.msg);
            }
            layer.closeAll('loading');
        }, 'json')
    });



    // $(".db-impor1t").click(function () {
    //     var url = $(this).attr('data-url');
    //     $('#form_tmp').attr('action', url);
    //     layer.load(1);
    //     $('#form_tmp').submit();
    // });

</script>
{/block}